#ifndef __DEVICE_H__
#define __DEVICE_H__
#include <common.h>

typedef void(*io_callback_t)(uint32_t, int, bool);

typedef struct {
  const char *name;
  uint64_t low;
  uint64_t high;
  void *space;
  io_callback_t callback;
} IOMap;

uint8_t* new_space(int size);
uint64_t mmio_read(uint64_t addr, size_t len);
void mmio_write(uint64_t addr, size_t len, uint64_t data);
void add_mmio_map(const char *name, uint64_t base, void *space, size_t size, io_callback_t callback);

#define CONFIG_DEVICE_BASE 0xa0000000
#define CONFIG_UART_BASE    CONFIG_DEVICE_BASE + 0x3f8
#define CONFIG_RTC_BASE     CONFIG_DEVICE_BASE + 0x48
#define CONFIG_UPTIME_BASE  CONFIG_DEVICE_BASE + 0x50
#define CONFIG_I8042_DATA_MMIO    CONFIG_DEVICE_BASE + 0x60

#endif